package com.hxx.day7;

import org.junit.Test;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * 属性对象
 */
public class TestDemo10 {
    public static void main(String[] args) {
        Properties properties = new Properties();
        //添加数据
        properties.put("name","张三");
        properties.put("age",18);
        properties.put("sex","男");
        // 遍历
        Set<Map.Entry<Object, Object>> entries = properties.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            System.out.println(entry.getKey() + "=" + entry.getValue());
        }
    }

    @Test
    public void test01(){
        Properties properties = new Properties();
        //添加数据:使用set或get对字符串操作的属性值
        properties.setProperty("name","张三");
        properties.setProperty("age","18");
        properties.setProperty("sex","男");
        // 遍历
        System.out.println(properties.getProperty("name"));
        System.out.println(properties.getProperty("age"));
        System.out.println(properties.getProperty("sex"));
    }
}

























